//
//  LEPresentingAnimatorTool.m
//  CreditAddressBook
//
//  Created by LE on 16/1/19.
//  Copyright © 2016年 Lee. All rights reserved.
//

#import "LEPresentingAnimatorTool.h"
#import "PresentingAnimator.h"
#import "DismissingAnimator.h"

@interface LEPresentingAnimatorTool ()<UIViewControllerTransitioningDelegate>

@end

@implementation LEPresentingAnimatorTool

+ (void)presentingAnimatorWithController:(UIViewController *)controller showIn:(UIViewController *)fromController completion:(void (^)(void))completion {
    controller.transitioningDelegate = [self self];
    controller.modalPresentationStyle = UIModalPresentationCustom;
    [fromController presentViewController:controller animated:YES completion:completion];
}

#pragma mark - UIViewControllerTransitioningDelegate
+ (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source {
    return [PresentingAnimator new];
}
+ (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed {
    return [DismissingAnimator new];
}
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source {
    return [PresentingAnimator new];
}
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed {
    return [DismissingAnimator new];
}
@end
